<?php
date_default_timezone_set('PRC');
$t=time();
$today=date('Y-m-d H:i:s',$t);
//连接到数据库
require 'conn.php';
$name=$_POST['name'];
$content=$_POST['content'];
// 将信息传递到数据库  执行
$sql="insert into notes (name,content,addtime) values('$name','$content','$today')";
$result=$db->query($sql); //执行sql语句 将结果赋给$result
$sql="select max(id) as id from nots";
$result=$db->query($sql);
if($result)
{
    echo "<script language='javascript'type='text/javascript'>";
    echo   " window.location.href='index.php';";
    echo    "</script>";
}
else
{
    echo "<script language='javascript'type='text/javascript'>";
    echo   " alert('添加失败');";
    echo   " window.location.href='index.php';";
    echo    "</script>";
}